﻿@model TestUp.Models.AdminModels.ViewTestsModel

@{
    ViewBag.Title = "View Tests";
    Layout = "~/Views/Admin/_AdminLayout.cshtml";
}

<h2>My Tests</h2>

@(Html.Kendo().Grid(Model.Tests)
    .Name("testsGrid")
    .Columns(cols =>
        {
            cols.Bound(x=>x.TestId).Hidden(true);
            cols.Bound(x=>x.TestName).Width("37.5%");
            cols.ForeignKey(x => x.CourseId, Model.Courses, "CourseId", "CourseName").Title("Course").Width("37.5%");
            cols.Command(cmd => cmd.Edit().Text("Edit").CancelText("Cancel").UpdateText("Apply"));
            cols.Command(cmd => cmd.Destroy().Text("Delete"));
        })
    .Editable(editable => editable.Mode(GridEditMode.PopUp).Window(window => window.Title("Edit Item")))
    .Groupable(x => x.Messages(builder => builder.Empty("Drop here some column header for groupping.")))
    .DataSource(dataSource => dataSource
        .Server()
        .Model(model =>
            {
                model.Id(x=>x.TestId);
                model.Field(x => x.TestId).Editable(false);
            })
        .Update(update => update.Action("EditTest", "Admin"))
        .Destroy(destroy => destroy.Action("DeleteTest", "Admin"))
        )
      )

<div id="CreateTestLink" class="k-button">
    @Html.ActionLink("New Test", "CreateTest", "Admin")
</div>